﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Snip
{
    public class SplitOptions : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private TimeSpan interval = TimeSpan.FromMinutes(5);
        private string destFolder = string.Empty;
        private bool saveInSameFolderAsSourceFile;
        private bool createSubfolders = true;
        private bool openDestFolderOnComplete = true;
        private bool deleteSourceFileOnComplete = false;

        public TimeSpan Interval
        {
            get { return interval; }
            set
            {
                if (interval != value)
                {
                    interval = value;
                    SendPropertyChanged("Interval");
                }
            }
        }

        public string DestFolder
        {
            get { return destFolder; }
            set
            {
                if (destFolder != value)
                {
                    destFolder = value;
                    SendPropertyChanged("DestFolder");
                }
            }
        }

        public bool SaveInSameFolderAsSourceFile
        {
            get { return saveInSameFolderAsSourceFile; }
            set
            {
                if (saveInSameFolderAsSourceFile != value)
                {
                    saveInSameFolderAsSourceFile = value;
                    SendPropertyChanged("SaveInSameFolderAsSourceFile");
                }
            }
        }

        public bool CreateSubFolders
        {
            get { return createSubfolders; }
            set
            {
                if (createSubfolders != value)
                {
                    createSubfolders = value;
                    SendPropertyChanged("CreateSubFolders");
                }
            }
        }

        public bool OpenDestFolderOnComplete
        {
            get { return openDestFolderOnComplete; }
            set
            {
                if (openDestFolderOnComplete != value)
                {
                    openDestFolderOnComplete = value;
                    SendPropertyChanged("OpenDestFolderOnComplete");
                }
            }
        }

        public bool DeleteSourceFileOnComplete
        {
            get { return deleteSourceFileOnComplete; }
            set
            {
                if (deleteSourceFileOnComplete != value)
                {
                    deleteSourceFileOnComplete = value;
                    SendPropertyChanged("DeleteSourceFileOnComplete");
                }
            }
        }

        private void SendPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public override string ToString()
        {
            return string.Format("SplitOptions {{ Interval = {0}, DestFolder = {1}, OpenDestFolderOnComplete = {2}, DeleteSourceFileOnComplete = {3} }}", Interval, DestFolder, OpenDestFolderOnComplete, DeleteSourceFileOnComplete);
        }
    }
}
